﻿using M_Purchase.Api.Appliction.Command.PurchCommand;
using M_Purchase.Repository.PurchaseInterface;
using MediatR;

namespace M_Purchase.Api.Appliction.CommandHandlers.PurchCommandHandler
{
    /// <summary>
    /// 删除采购信息
    /// </summary>
    public class PurchDeleteCommandHandler : IRequestHandler<PurchDeleteCommand, int>
    {
        private readonly IPurchRepository _purchRepository;
        public PurchDeleteCommandHandler(IPurchRepository purchRepository)
        {
            _purchRepository = purchRepository;
        }
        public async Task<int> Handle(PurchDeleteCommand request, CancellationToken cancellationToken)
        {
            var PDList = await _purchRepository.GetModelsAsync(request.PurchaseID);
            PDList.IsDeleted=true;
            return await _purchRepository.UpdateAsync(PDList);
        }
    }
}
